Skip to content

gpu-config [1/13]: add the GPU configuration state file - #3247

Open
henry118 wants to merge 1 commit into
NVIDIA:mainfrom
henry118:gpu-config/01-statefile
Open

henry118 wants to merge 1 commit into
NVIDIA:mainfrom
henry118:gpu-config/01-statefile

Conversation

@henry118

@henry118 henry118 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Part of #3246 (1/13). Depends on: none.

Adds internal/gpuconfig/statefile: the node-local state file and lock that
the GPU configuration manager and the gpu-config init container use to
record the decision and the gate pass for each driver load. Not used yet.


Devin Review

@henry118
henry118 requested a review from a team as a code owner November 17, 2026 18:23

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

The change adds a versioned JSON state model with parsing, state predicates, and config lookup. It adds a store that reads state files and provides blocking and nonblocking advisory locks. Locked writes record apply decisions or gate passes, preserve other top-level keys, and replace the state file through a temporary file. Tests cover parsing, predicates, locking, write behavior, and timestamps.

Estimated code review effort:

Merge Risk: Low · up to 1b629

This adds a node-local GPU state file that nothing uses yet, so production exposure is minimal. A hand-edited file with duplicate version keys could be accepted on read and then become unreadable after the next write. Fixing that edge case, or rejecting ambiguous duplicate fields, is worthwhile before the state file is wired in.

Security architecture risk: Minimal · up to 1b629

The new state-storage contract merits review, but this change does not connect it to running GPU configuration or allocation flows. The inspected locking, read-before-write and atomic-replacement behavior establishes no material security, failure-containment or ownership regression.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The established scope is the node-local state store, not an exposed network or tenant API. The PR explicitly defers production use, and the supplied reachability summary reports no downstream files outside the package. Future integration could make these records authoritative for GPU allocation, but that exposure is not introduced here.

Trust Boundaries and Controls

  • observed — File contents cross into typed state through JSON decoding and version validation. Unknown decision values do not satisfy Decided, and WriteApply rejects values other than applied or skipped. Correct load identity remains a caller contract: WriteGatePass documents the required load relationship but does not verify it.

Resilience and Maintainability Implications

  • observed — Acquisition retries interrupted flock operations and closes the file on acquisition failure. A failed locked read invalidates the write base, and writes after unlock are rejected. These controls prevent cooperating sequential holders from carrying a stale read across failed validation or a completed lock hold.

Hardening Proposals

  • proposed — Before production integration, explicitly establish trusted directory ownership and mount permissions, single-owner use of each Lock, and the source of current-load identity. Validate those responsibilities where the manager and gate acquire authority over this store.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Other comments: 1

internal/gpuconfig/statefile/state.go: 1

101-101: Minor · Data Integrity & Integration · Quick win

Keep the decoded state consistent with the retained JSON.

{"version":1,"version":null} passes the first decode with Version == 1, but this decode retains version:null. Go leaves a scalar unchanged when decoding null. (raw.githubusercontent.com)

After a successful Lock.Read, WriteGatePass copies that null version into the replacement file. It then returns ErrParse after the rename. Subsequent reads also fail.

Derive State from the retained representation, or reject ambiguous duplicate fields before accepting the file. Add a read–write regression test.

Nitpick comments: 1

internal/gpuconfig/statefile/file_test.go: 1

219-219: Trivial · Maintainability & Code Quality · Quick win

Exercise a failed read after a successful read.

This test starts with l.base == nil. It still passes if Lock.Read stops clearing a previous successful base after an error.

First perform a successful l.Read. Then replace the fixture with {"version":2}, repeat the read, and keep the write-rejection and unchanged-file assertions. This catches a stale base that could overwrite an unreadable file.

As per path instructions, “Flag assertions that would still pass if the behavior under test were broken.”

Source: Path instructions

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 246a9ca and 1b62959.

Files selected for processing: 4

  • internal/gpuconfig/statefile/file.go
  • internal/gpuconfig/statefile/file_test.go
  • internal/gpuconfig/statefile/state.go
  • internal/gpuconfig/statefile/state_test.go

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Signed-off-by: Henry Wang <henrwang@nvidia.com>
@henry118
henry118 force-pushed the gpu-config/01-statefile branch from 6ee993d to 46152a7 Compare November 19, 2026 00:16
@henry118 henry118 changed the title gpu-config: add the GPU configuration state file gpu-config [1/13]: add the GPU configuration state file Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant